package yf.mall.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * 集合相关工具类
 *
 * @author yxmds
 */
public final class CollUtil {

    private CollUtil() {
    }

    public static <T>  List<List<T>> groupList(List<T> inputList, int groupSize) {
        List<List<T>> groupedLists = new ArrayList<>();

        for (int i = 0; i < inputList.size(); i += groupSize) {
            int endIndex = Math.min(i + groupSize, inputList.size());
            List<T> subList = inputList.subList(i, endIndex);
            groupedLists.add(subList);
        }

        return groupedLists;
    }
}
